package interface1;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.table.DefaultTableModel;

import back_database.Select_Means;
import front_shop.cashierFrame;
import front_shop.replenish;
import front_shop.return_sales;

public class ItemListener implements ActionListener {

	private static final int DISPOSE_ON_CLOSE = 0;

	@Override
	public void actionPerformed(ActionEvent e) {
		JMenuItem menuItem = (JMenuItem) e.getSource();
		System.out.println("您单击的是菜单项：" + menuItem.getText());

		// 退出
		if (e.getSource() == Admin.exit) {
			System.exit(0);

		} else if (e.getSource() == Admin.front) { // 转前台
			/*
			 * Administrator login = new Administrator(); login.setBounds(300,
			 * 200, 400, 300); login.setVisible(true); login.validate();
			 * login.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
			 */

			cashierFrame cashierframe = new cashierFrame();
			cashierframe.setTitle("超市前台收银系统 ");
			cashierframe.setBounds(100, 100, 700, 500);
			cashierframe.setVisible(true);
			cashierframe.validate();
			cashierframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

		} else if (e.getSource() == Admin.purchase2) { // 采购
			// 进货

			replenish user = new replenish();
			user.setTitle("进货 ");
			user.setBounds(200, 200, 500, 400);
			user.setVisible(true);
			user.validate();
			user.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

		} else if (e.getSource() == Admin.returnSales) { // 退货
			// 进货

			return_sales user = new return_sales();
			user.setTitle("退货 ");
			user.setBounds(200,200,500,170);
			user.setVisible(true);
			user.validate();
			user.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

		} else if (e.getSource() == Admin.cashbalance) { // 收支信息
			Admin.columnNames = Admin.createColumnNames(Admin.select_meands.SELECT_CASHBALANCE);
			Admin.data = new Select_Means().Select_CashBalance();
			Admin.defaultModel = new DefaultTableModel(Admin.data, Admin.columnNames);// 创建一个默认的表格模型
			Admin.table.setModel(Admin.defaultModel);

		} else if (e.getSource() == Admin.buyInfor) { // 采购信息

			Admin.columnNames = Admin.createColumnNames(Admin.select_meands.SELECT_PURCHASE);
			Admin.data = new Select_Means().selectPurchase();
			Admin.defaultModel = new DefaultTableModel(Admin.data, Admin.columnNames);// 创建一个默认的表格模型
			Admin.table.setModel(Admin.defaultModel);

		} else if (e.getSource() == Admin.refundInfor) { // 退货信息

			Admin.columnNames = Admin.createColumnNames(Admin.select_meands.SELECT_REFUND); // 2021
			Admin.data = new Select_Means().selectRefund();
			Admin.defaultModel = new DefaultTableModel(Admin.data, Admin.columnNames); // 创建一个默认的表格模型
			Admin.table.setModel(Admin.defaultModel);

		}

		// purchase.add(buyInfor);
		// purchase.add(refundInfor);

	}

}